package cn.hxzy.servlet;

import cn.hxzy.entity.Work;
import cn.hxzy.service.WorkService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/showWork")
public class ShowWorkServlet extends HttpServlet {
    WorkService workService=new WorkService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            String id = req.getParameter("id");
            Work  byId = workService.findByIdWithUser(Integer.parseInt(id));
            System.out.println(byId);
            req.setAttribute("work",byId);
            req.getRequestDispatcher("WEB-INF/jsp/showWork.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
